package array;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-07-06
 * Time: 19:43
 */
public class MyArray1 {
    public Object[] array = new Object[20];

    public Object getArray(int pos) {
        return array[pos];
    }

    public void setArray(Object val, int pos) {
        this.array[pos] = val;
    }

    public static void main(String[] args) {
        MyArray1 myArray1 = new MyArray1();
        /**
         * 1.可以放的元素类型太庞杂
         */
        myArray1.setArray(1,0);
        myArray1.setArray("heh", 1);


        System.out.println(myArray1.getArray(0));

        //类型不一致每次还要进行向上转型，太麻烦
        String str1 = (String) myArray1.getArray(1);
    }
}
